package com.digital.herbarium.Controller;

import com.digital.herbarium.Entity.AboutUs;
import com.digital.herbarium.annotation.CheckToken;
import com.digital.herbarium.Entity.ResponseResult;
import com.digital.herbarium.annotation.Log;
import com.digital.herbarium.service.AboutUsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/aboutus")
public class AboutUsController {

    @Autowired
    AboutUsService aboutUsService;


    @GetMapping("getAboutUsInfo")
    @Log("aboutus")
    public ResponseResult getAboutUsInfo(AboutUs aboutUs){
        return ResponseResult.SUCCESS().setData( aboutUsService.getAboutUsInfo(aboutUs));
    }


    @GetMapping("getManagerAboutUsInfo")
    @CheckToken()
    @Log("aboutus")
    public ResponseResult getManagerAboutUsInfo(AboutUs aboutUs){
        return ResponseResult.SUCCESS().setData( aboutUsService.getAboutUsInfo(aboutUs));
    }


    @PostMapping("addAboutUsInfo")
    @CheckToken()
    public  ResponseResult addAboutUsInfo(AboutUs  aboutUs){
        aboutUsService.addAboutUsInfo(aboutUs);
        return ResponseResult.SUCCESS().setData("添加成功");
    }

    @PostMapping("editAboutUsInfo")
    @CheckToken()
    public  ResponseResult editAboutUsInfo(AboutUs aboutUs){
        aboutUsService.editAboutUsInfo(aboutUs);
        return ResponseResult.SUCCESS().setData("更新成功");
    }

    @GetMapping("delAboutUsInfo")
    @CheckToken()
    public ResponseResult delAboutUsInfo(String id){
        aboutUsService.delAboutUsInfo(id);
        return  ResponseResult.SUCCESS().setData("删除成功");
    }
}
